<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>用户列表</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<!-- Add by Kravis Liu 2014.09.22 -->
		<link rel="stylesheet" href="/css/base.css" />
		<link rel="stylesheet" href="/css/list2.css" />
		<script src="/js/jquery-1.11.1.min.js"></script>
		<script type="text/javascript">
			
			function deleteUser(userId){
				if(confirm("是否删除用户?")){
					$.ajax({
					   type: "POST",
					   url: "/app/deleteUser",
					   data: "userId=" + userId,
					   success: function(msg){
						 if(msg == "success"){
							 alert("操作成功！");
							 $("#"+userId).hide();			 
						 }
					   }
					});					
				}
	
			}
			
			function openUser(userId){
				$.ajax({
				   type: "POST",
				   url: "/app/openUser",
				   data: "userId=" + userId
				});	
			}
		</script>
	
	</head>

	<body>
		<div id="page">
			<div id="header">
				<h4>后台管理</h4>
			</div>
			
		
			<table width="98%" border="1" align="center" cellpadding="0" cellspacing="0">
				<tbody id="add_point">
					<tr>
						<td><div align="center">用户名</div></td>
						<td><div align="center">昵称</div></td>
						<td><div align="center">用户类型</div></td>
						<td><div align="center">用户状态</div></td>
						<td><div align="center">操作</div></td>
					</tr>
				
				<% if (Users){ %>
				<%  Users.forEach(function (user){ %>	
					<tr id="<%= user.id%>">
						<td><div align="center"><a href="/app/openUser?userId=<%= user.id %>" ><%= user.get('username') %></a></div></td>
						<td><div align="center"><%= user.get('nickname') %></div></td>
						<%if (user.get('usertype') == "1"){%>
						<td><div align="center">活动员</div></td>
						<%} else {%>
						<td><div align="center">普通用户</div></td>
						<%}%>
						<%if (user.get('usable') == "0"){%>
						<td><div align="center">停用</div></td>
						<%} else {%>
						<td><div align="center">启用</div></td>
						<%}%>
						<td><div align="center"><a href="javascript:void(0)" onClick="deleteUser('<%= user.id%>');">删除</a></div></td>
					</tr>
				<% })} %>
				
				</tbody>
			</table>
			<p>&nbsp;</p>
			
			<div id="footer">			
				<a style="float:right;margin:5px" href="/logout">退出</a>
				<a style="float:right;margin:5px" href="/app/index">主页</a>
				<% if(next != 0){ %>
					<a style="float:right;margin:5px" href="/app/userList?page=<%=next%>">下一页</a>
				<%}%>					
				<% if(previous >= 0){ %>
					<a style="float:right;margin:5px" href="/app/userList?page=<%=previous%>">上一页</a>
				<%}%>				
			</div>
		</div>
	</body>
</html>
